<template>
  <!-- 账号与安全 -->
  <view class="pd">
    <uni-list>
      <uni-list-item
        :title="item.title"
        v-for="(item, index) in uniList"
        :key="index"
        clickable
        :rightText="item.value"
        @click="open(item.type)"
      >
      </uni-list-item>
    </uni-list>
  </view>
</template>

<script>
import { mapState } from "vuex";

export default {
  computed: {
    ...mapState(["userInfo"]),
  },
  data() {
    return {
      uniList: [],
    };
  },
  onReady() {
    // console.log(1);
    let list = [
      {
        title: "手机号",
        value: this.userInfo.phone ? this.userInfo.phone : "未绑定",
        type: "phone",
      },
      {
        title: "登录密码",
        value: this.userInfo.password ? "修改密码" : "未设置",
        type: "password",
      },
      {
        title: "绑定邮箱",
        value: this.userInfo.email ? this.userInfo.email : "未绑定",
        type: "email",
      },
      // {
      //   title: "微信账号",
      //   value: "未绑定",
      //   type: "wx",
      // },
      // {
      //   title: "微博账号",
      //   value: "未绑定",
      //   type: "weibo",
      // },
      // {
      //   title: "QQ账号",
      //   value: "未绑定",
      //   type: "QQ",
      // },
    ];
    this.uniList = [...list];
  },
  methods: {
    open(type) {
      if (type === "phone" || type === "password" || type === "email") {
        uni.navigateTo({
          url: `../user-${type}/user-${type}`,
        });
      } else {
      }
    },
  },
};
</script>

<style></style>
